using System.Text;
using UnityEngine;

namespace Demo2048
{
    public class BackGround : MonoBehaviour
    {
        // Start is called before the first frame update
        void Awake()
        {
            Init();
        }

        void Init()
        {
            m_containers = new Transform[Config.m_r, Config.m_c];
            for (int i = 0; i < Config.m_r; i++)
            {
                for (int j = 0; j < Config.m_c; j++)
                {
                    GameObject obj = Create(i, j);
                    m_containers[i, j] = obj.transform;
                }
            }
        }

        GameObject Create(int r, int c)
        {
            GameObject obj = GameObject.Instantiate(m_container);
            obj.name = m_container.name + r.ToString() + '-' + c.ToString();
            obj.transform.SetParent(transform, false);
            return obj;
        }

        public Transform GetTrans(int r, int c)
        {
            return m_containers[r, c];
        }

        public GameObject m_container;
        private Transform[,] m_containers;
    }
}
